import {SysUser, SysUserProfile, type SysUserRestPassword} from "@/api/user/types.ts";
import {request} from "@/api";
import {Page} from "@/api/types.ts";

const apiPrefix = '/varian-system/user'

export const userApi = {
    add: (data: SysUser) => request.post(`${apiPrefix}`, {data}),
    page: (params: any) => request.get<Page<SysUser>>(`${apiPrefix}/page`, {params}),
    list: (params: any) => request.get<SysUser[]>(`${apiPrefix}/list`, {params}),
    modify: (data: SysUser) => request.put(`${apiPrefix}/${data.id}`, {data}),
    detail: (id: string) => request.get<SysUser>(`${apiPrefix}/${id}`),
    grantedList: (id: string) => request.get<{ roleIds: string[] }>(`${apiPrefix}/grant/${id}`),
    grant: (data: any) => request.put(`${apiPrefix}/grant/${data.id}`, {data}),
    userProfile: () => request.get<SysUserProfile>(`${apiPrefix}/user-profile`),
    modifyUserProfile: (data: any) => request.put(`${apiPrefix}/user-profile`, {data}),
    resetPassword: (data: SysUserRestPassword) => request.put(`${apiPrefix}/reset-password`, {data})
}
